package tech.shupi.babytaptv.database

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

/**
 * Room Entity for Card table in BabyTapTV
 */
@Entity(tableName = "cards")
data class CardEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,
    val title: String,
    val front_image: String,
    val back_text: String,
    @ColumnInfo(defaultValue = "")
    val audio_path: String = "",
    @ColumnInfo(defaultValue = "")
    val uuid: String = "",
    val created_at: String,
    val updated_at: String
) {
    /**
     * Convert Entity to Domain Model
     */
    fun toCard(): tech.shupi.babytaptv.types.Card {
return tech.shupi.babytaptv.types.Card(
            id = id,
            title = title,
            front_image = front_image,
            back_text = back_text,
            audio_path = audio_path,
            uuid = uuid,
            created_at = created_at,
            updated_at = updated_at
        )
    }
    
    /**
     * Convert Domain Model to Entity
     */
    companion object {
        fun fromCard(card: tech.shupi.babytaptv.types.Card): CardEntity {
            return CardEntity(
                id = card.id,
                title = card.title,
                front_image = card.front_image,
                back_text = card.back_text,
                audio_path = card.audio_path ?: "",
                uuid = card.uuid ?: "",
                created_at = card.created_at,
                updated_at = card.updated_at
            )
        }
    }
} 